import en from "../i18n/lang/en"
import Vue from "vue"
import Router from "vue-router"
import CommerViews from "@/views/commerViews"
import Login from "@/views/login/index"
import Layout from "@/views/layout/layout"
import HomeMain from "@/views/index/mainIndex"
import sysDict from "../views/dictData/sysDict"


// 不是必须加载的组件使用懒加载
const Icon = () => import("@/views/icon/index")
const Erji = () => import("@/views/duoji/erji")
const Erji2 = () => import("@/views/duoji/erji2")
const Sanji = () => import("@/views/duoji/sanji")
const Sanji2 = () => import("@/views/duoji/sanji2")
const Siji = () => import("@/views/duoji/siji")
const Wuji = () => import("@/views/duoji/wuji")
const Transfer = () => import("@/views/transfer/transfer")
const DataTable = () => import("@/views/table/dataTables")
const FilterTable = () => import("@/views/table/filterTable")
const DragTable = () => import("@/views/table/dragTabe")
const Upload = () => import("@/views/upload/upload")
const Markdown = () => import("@/views/editor/markdownView")
const WangeditorView = () => import("@/views/editor/wangeditorView")
const NotFound = () => import("@/views/page404")
const AddArticle = () => import("@/views/article/addArticle")
const AddArticleEditor = () => import("@/views/article/addArticleEditor")
const NavClassify = () => import("@/views/syssetting/navClassify")
const pagePermissions = () => import("@/views/permissions/pagePermissions")
const btnPermissions = () => import("@/views/permissions/btnPermissions")
const SpuList = () => import("@/views/spu/spuList")
const BrandList = () => import("@/views/brand/brandList")

const KindsList = () => import("@/views/kinds/kindsList")
const SpuAttrList = () => import("@/views/kinds/attr/spuAttrList")
const SpuAttrValueList = () => import("@/views/kinds/attr/value/SpuAttrValueList")
const Merchant = () => import("@/views/merchant/MerchantAccount")
const StoreInfo = () => import("@/views/merchant/MerchantInfo")
const StoreAudit = () => import("@/views/merchant/MerchantAudit")
const AddStore = () => import("@/views/merchant/addMerchant")
const CouponList = () => import("@/views/promotion/couponList")

const CouponInfo = () => import("@/views/promotion/couponInfo")
const SpuAdd = () => import("@/views/spu/SpuAdd")
const admin = () => import("@/views/admin/adminUser")
const HomeBillboardsList = () => import("@/views/homebillboards/HomeBillboardsList")
const Task = () => import("@/views/task/Task")
const sysdict = () => import("@/views/dictData/sysdict")
const OuZeChangShaBi = () => import("@/views/user/userList")
const OuZeChangShaBiSecond = () => import("@/views/user/merchantList")
const dictItem = () => import("@/views/dictData/child/dictItem")
const OuZeChangDaShaBi = () => import("@/views/user/userCollect")
const massage = () => import("@/views/massage/massage")
const OuZeChangDaErShaBi = () => import("@/views/user/userFoot")
const SpuUpdate = () =>  import("@/views/spu/SpuUpdate")
const Order = () =>  import("@/views/order/OrderList")
const commentList = () =>  import("@/views/comment/commentList")
/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return routerPush.call(this, location).catch(error => error)
}
Vue.use(Router)
let routeName = en.routeName
let defaultRouter = [
  {
    path: "/",
    redirect: "/index",
    hidden: true,
    children: []
  },
  {
    path: "/login",
    component: Login,
    name: "",
    hidden: true,
    children: []
  },
  {
    path: "/index",
    iconCls: "fa fa-dashboard", // 图标样式class
    name: routeName.home,
    component: Layout,
    alone: true,
    children: [
      {
        path: "/index",
        iconCls: "fa fa-dashboard", // 图标样式class
        name: "主页",
        component: HomeMain,
        children: []
      }
    ]
  },
  {
    path: "/404",
    component: NotFound,
    name: "404",
    hidden: true,
    children: []
  },

]

let addRouter = [
  {
    path: "/",
    iconCls: "el-icon-user-solid", // 图标样式class
    name: routeName.user,
    component: Layout,
    children: [
      {
        path: "/OuZeChangShaBi",
        iconCls: "el-icon-magic-stick", // 图标样式class
        name: routeName.userAccount,
        component: OuZeChangShaBi,
        children: []
      },
      {
        path: "/OuZeChangShaBiSecond",
        iconCls: "el-icon-magic-stick", // 图标样式class
        name: routeName.merchantList,
        component: OuZeChangShaBiSecond,
        children: []
      },
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-universal-access", // 图标样式class
    name: routeName.store,
    component: Layout,
    children: [
      {
        path: "/merchantAccouont",
        iconCls: "fa fa-expeditedssl", // 图标样式class
        name: routeName.storeAccount,
        component: Merchant,
        children: []
      },
      {
        path: "/merchanInfo",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.storeInfo,
        hidden: true,
        component: StoreInfo,
        children: []
      },
      {
        path: "/merchantAudit",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.storeAudit,
        component: StoreAudit,
        children: []
      },
      {
        path: "/addMerchant",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.storeAdd,
        hidden: true,
        component: AddStore,
        children: []
      },

    ]
  },

  {
     path: "/",
     iconCls: "fa fa-universal-access", // 图标样式class
     name: routeName.coupon,
     component: Layout,
     children: [
       {
         path: "/couponList",
         iconCls: "fa fa-expeditedssl", // 图标样式class
         name: routeName.couponList,
         component: CouponList,
         children: []
       },
       {
         path: "/couponInfo",
         iconCls: "fa fa-expeditedssl", // 图标样式class
         name: routeName.couponInfo,
         hidden: true,
         component: CouponInfo,
         children: []
       },
     ]
   },
  {
    path: "/",
    iconCls: "el-icon-tickets", // 图标样式class
    name: routeName.article,
    component: Layout,
    children: [
      {
        path: "/addArticle",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.publishArticle,
        component: AddArticle,
        children: []
      },
      {
        path: "/addArticleEditor",
        iconCls: "el-icon-edit-outline", // 图标样式class
        name: routeName.publishArticleEditor,
        hidden: true,
        component: AddArticleEditor,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.spuAdmin,
    component: Layout,
    children: [
      {
        path: "/spuList",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.spuList,
        component: SpuList,
        children: []
      },
      {
        path: "/spuUpdate",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.spuUpdate,
        component: SpuUpdate,
        children: [],
        hidden: true,
      },
      {
        path: "/spuAdd",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.addSpu,
        component: SpuAdd,
        children: [],
        hidden: true,
      }
    ]
  }, {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.homebillboards,
    component: Layout,
    children: [
      {
        path: "/homebillboardsList",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.homebillboardsList,
        component: HomeBillboardsList,
        children: []
      }
    ]
  },

  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.order,
    component: Layout,
    children: [
      {
        path: "/Order",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.orderList,
        component: Order,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.comment,
    component: Layout,
    children: [
      {
        path: "/commentList",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.commentList,
        component: commentList,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.brandAdmin,
    component: Layout,
    children: [
      {
        path: "/brandList",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.brandList,
        component: BrandList,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.kindsAdmin,
    component: Layout,
    children: [
      {
        path: "/kindsList",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.kindsList,
        component: KindsList,
        children: []
      }
    ]
  },

  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    component: Layout,
    children: [
      {
        path: "/OuZeChangDaShaBi/:item",
        name: "OuZeChangDaShaBi",
        component: OuZeChangDaShaBi,
        hidden: true
      }
    ],
    hidden: true
  },

  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    component: Layout,
    children: [
      {
        path: "/OuZeChangDaErShaBi/:item",
        name: "OuZeChangDaErShaBi",
        component: OuZeChangDaErShaBi,
        hidden: true
      }
    ],
    hidden: true
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    component: Layout,
    children: [
      {
        path: "/attr/spuAttrList",
        name: "spuAttrList",
        component: SpuAttrList,
        hidden: true
      }
    ],
    hidden: true
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    component: Layout,
    children: [
      {
        path: "/attr/value/spuAttrValueList",
        name: "spuAttrValueList",
        component: SpuAttrValueList,
        hidden: true
      }
    ],
    hidden: true
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.task,
    component: Layout,
    children: [
      {
        path: "/task",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.task,
        component: Task,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-paw", // 图标样式class
    name: routeName.icon,
    component: Layout,
    children: [
      {
        path: "/icon",
        iconCls: "fa fa-life-ring", // 图标样式class
        name: routeName.builtInIcon,
        component: Icon,
        children: []
      }
    ]
  },

  {
    path: "/",
    iconCls: "fa fa-exchange", // 图标样式class
    name: routeName.shuttleBox,
    component: Layout,
    children: [
      {
        path: "/transfer",
        iconCls: "fa fa-sign-in", // 图标样式class
        name: routeName.demoShuttle,
        component: Transfer,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-universal-access", // 图标样式class
    name: routeName.permissions,
    component: Layout,
    children: [
      {
        path: "/pagePermissions",
        iconCls: "fa fa-expeditedssl", // 图标样式class
        name: routeName.pageControl,
        component: pagePermissions,
        children: []
      },
      {
        path: "/btnPermissions",
        iconCls: "fa fa-toggle-on", // 图标样式class
        name: routeName.btnControl,
        component: btnPermissions,
        children: []
      },
      {
        path: "/admin",
        iconCls: "el-icon-custom", // 图标样式class
        name: routeName.admin,
        component: admin,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-universal-access", // 图标样式class
    name: routeName.dict,
    component: Layout,
    children: [
      {
        path: "/sysDict",
        iconCls: "fa fa-expeditedssl", // 图标样式class
        name: routeName.dict,
        component: sysDict,
        children: []
      },
      {
        path: "/dictItem",
        component: dictItem,
        hidden: true,
        children: []
      },
    ]
  },
  {
    path: "/",
    iconCls: "el-icon-chat-dot-round", // 图标样式class
    name: routeName.massage,
    component: Layout,
    children: [
      {
        path: "/massage",
        iconCls: "el-icon-message", // 图标样式class
        name: routeName.massage,
        component: massage,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-newspaper-o", // 图标样式class
    name: routeName.table,
    component: Layout,
    children: [
      {
        path: "/dataTable",
        iconCls: "fa fa-sliders", // 图标样式class
        name: routeName.multiDataTable,
        component: DataTable,
        children: []
      },
      {
        path: "/filterTable",
        iconCls: "fa fa-sort-amount-asc", // 图标样式class
        name: routeName.filterTable,
        component: FilterTable,
        children: []
      },
      {
        path: "/dragTabe",
        iconCls: "fa fa-hand-stop-o", // 图标样式class
        name: routeName.dragSort,
        component: DragTable,
        children: []
      }
    ]
  },

  {
    path: "/",
    iconCls: "fa fa-server",
    name: routeName.multiDirectory,
    component: Layout,
    children: [
      {
        path: "/erji1",
        iconCls: "fa fa-server",
        name: routeName["menu2-1"],
        component: Erji,
        children: []
      },
      {
        path: "/erji2",
        iconCls: "fa fa-server",
        name: routeName["menu2-2"],
        component: Erji2,
        children: []
      },
      {
        path: "/erji3",
        iconCls: "fa fa-server",
        name: routeName["menu2-3"],
        component: CommerViews, // 无限极菜单的容器
        children: [
          {
            path: "/sanji1",
            iconCls: "fa fa-server",
            name: routeName["menu3-1"],
            component: Sanji,
            children: []
          },
          {
            path: "/sanji2",
            iconCls: "fa fa-server",
            name: routeName["menu3-2"],
            component: Sanji2,
            children: []
          },
          {
            path: "/sanji3",
            iconCls: "fa fa-server",
            name: routeName["menu3-3"],
            component: CommerViews,
            children: [
              {
                path: "/siji",
                iconCls: "fa fa-server",
                name: routeName["menu4-1"],
                component: Siji,
                children: []
              },
              {
                path: "/siji1",
                iconCls: "fa fa-server",
                name: routeName["menu4-2"],
                component: CommerViews,
                children: [
                  {
                    path: "/wuji",
                    iconCls: "fa fa-server",
                    name: routeName["menu5-1"],
                    component: Wuji,
                    children: []
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  {
    path: "/",
    iconCls: "fa fa-cloud-upload", // 图标样式class
    name: routeName.upload,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        path: "/upload",
        iconCls: "el-icon-upload2", // 图标样式class
        name: routeName.fileUpload,
        component: Upload,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "el-icon-edit", // 图标样式class
    name: routeName.editor,
    component: Layout,
    meta: {role: ["superAdmin", "admin"]},
    children: [
      {
        path: "/markdown",
        iconCls: "fa fa-file-code-o", // 图标样式class
        name: routeName.markdown,
        component: Markdown,
        children: []
      },
      {
        path: "/wangeditor",
        iconCls: "fa fa-file-code-o", // 图标样式class
        name: routeName.wangeditor,
        component: WangeditorView,
        children: []
      }
    ]
  },
  {
    path: "/",
    iconCls: "el-icon-setting", // 图标样式class
    name: routeName.systemSettings,
    component: Layout,
    meta: {role: ["superAdmin"]},
    children: [
      {
        path: "/navClassifies",
        iconCls: "el-icon-menu", // 图标样式class
        name: routeName.navMenu,
        component: NavClassify,
        children: []
      }
    ]
  },
  {
    path: "*",
    redirect: "/404",
    hidden: true,
    children: []
  }

]
export default new Router({
  routes: defaultRouter
})
export {defaultRouter, addRouter}
